package com.xy.Test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * projectName:BK-2109
 * author:xiaoyang
 * time:2022/3/7 17:29
 * description:
 */
public class EsClient {

    //获取和es服务器的连接
    public static RestHighLevelClient getClient(){

        HttpHost httpHost=new HttpHost("192.168.159.130",9200);

        RestClientBuilder builder= RestClient.builder(httpHost);

        RestHighLevelClient restHighLevelClient=new RestHighLevelClient(builder);

        return  restHighLevelClient;

    }
}
